package com.cdn.clock.config;

/**
 * 蔡定努
 * 2024/06/25 18:01
 */

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;


public class ClogThreadPoolTask {

    private final  ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    private static final Log log = LogFactory.getLog(ClogThreadPoolTask.class);


    public void init() {
        taskScheduler.setPoolSize(Runtime.getRuntime().availableProcessors() * 2);
        taskScheduler.setThreadNamePrefix("redis-add-time-");
        taskScheduler.setAwaitTerminationSeconds(60);
        taskScheduler.initialize();
        log.info("redis-add-time-线程池初始化成功");
    }


    public ThreadPoolTaskScheduler getTaskScheduler() {
        return taskScheduler;
    }


    public void shutdown() {
        taskScheduler.shutdown();
        log.info("redis-add-time-线程池关闭成功");
    }
}
